#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef int Position;
typedef struct LNode *List;
struct LNode
{
    double *Data;
    Position Last;
    int Length;
};

List Make_Empty(int Element_number)
{
    List L;
    L = (List)malloc(sizeof(struct LNode));
    L->Data = (double*)malloc(sizeof(double) * Element_number);
    L->Last = -1;
    L->Length = Element_number;
    return L;
}

bool Insert(List L, double X)
{
    if (L->Last + 1 == L->Length)
    {
        printf("List is full !");
        return false;
    }
    else
    {
        L->Data[++L->Last] = X;
        return true;
    }
}

void Get_Max_Length(List L)
{
    int now_length = 1, max_length = 1,
        max_Left = 0, max_Right = 0,
        index = 0;

    for (; index <= L->Last; index++)
    {
        if (L->Data[index] < L->Data[index + 1])
        {
            now_length++;
        }
        else
        {
            if (max_length < now_length)
            {
                max_length = now_length;
                max_Left = index - max_length + 1;
                max_Right = index;
            }
            now_length = 1;
        }
    }

    printf("\nMax length of increasing vector is %d !\n", max_length);
    for (int i = max_Left; i <= max_Right; i++)
        printf("%lf  ", L->Data[i]);
}


int main()
{
    int length;
    double number;
    printf("Enter the length of list: ");
    scanf("%d", &length);

    List example_list = Make_Empty(length);
    for (;;)
    {
        printf("Enter the number to input(0 to finish) : ");
        scanf("%lf", &number);
        if (number == 0)
            break;
        if (Insert(example_list, number))
            printf("Insert success !\n");
        else
            break;
    }
    printf("\n\n");

    for (int index = 0; index <= example_list->Last; index++)
        printf("%lf ", example_list->Data[index]);

    Get_Max_Length(example_list);

    return 0;
}